package com.vdong.task.job.service.jobhandler;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vdong.trade.trading.facade.TransactionPayFacade;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * 通过nonce_str查询微信支付订单,并做相关回调处理
 *
 * @author clf
 * @Date 2018/12/24 11:24
 */
@JobHandler(value = "wechatNotifyOrderQueryHandler")
@Component
public class WechatNotifyOrderQueryHandler extends IJobHandler {

    @Reference
    private TransactionPayFacade transactionPayFacade;

    @Override
    public ReturnT<String> execute(String param) throws Exception {
        XxlJobLogger.log("wechatNotifyOrderQueryHandler-job-start============");
        if (StringUtils.isBlank(param)) {
            XxlJobLogger.log("wechatNotifyOrderQueryHandler-job任务参数异常!");
            return FAIL;
        }
        String result = transactionPayFacade.queryWaitAsyncNotifyOrder(param);
        XxlJobLogger.log("wechatNotifyOrderQueryHandler-job ==>  result:[{}]", result);
        XxlJobLogger.log("wechatNotifyOrderQueryHandler-job-end============");
        return SUCCESS;
    }
}
